package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.NumAndYardDTO;
import com.CST.dto.ys.YsBusinessBudgetDTO;
import com.CST.entity.ys.YsAssetModifyRecords;
import com.CST.entity.ys.YsEtlAssetDetails;
import com.CST.service.ys.YsManageAssetService;
import com.CST.vo.ys.YsManageAssetVO;
import com.CST.vo.ys.YsModifyRecordVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * 管理预算执行管理--资产类
 * @author cw
 */
@Api(tags={"管理预算执行管理--资产类"})
@RestController
@RequestMapping("/ysManageAsset")
public class YsManageAssetController {
    @Autowired
    private YsManageAssetService ysManageAssetService;

    @ApiOperation("查询资产类列表")
    @PostMapping("/getAssetInfoList")
    public ResultObject<YsManageAssetVO> getAssetInfoList(@RequestBody YsBusinessBudgetDTO dto){
        return ResultObject.success(ysManageAssetService.getAssetInfoList(dto));
    }

    @ApiOperation("新增资产")
    @PostMapping("/insertManageAsset")
    public ResultObject<Integer> insertManageAsset(@RequestBody YsEtlAssetDetails ysEtlAssetDetails){
        return ResultObject.success(ysManageAssetService.insertManageAsset(ysEtlAssetDetails));
    }

    @ApiOperation("编辑回显数据")
    @GetMapping("/getInfoByNum/{id}")
    public ResultObject<YsEtlAssetDetails> getInfoByNum(@PathVariable Integer id){
        return ResultObject.success(ysManageAssetService.selectInfoByNum(id));
    }

    @ApiOperation("更新资产")
    @PostMapping("/updateManageAssetByNum")
    public ResultObject<Integer> updateManageAssetByNum(@RequestBody YsEtlAssetDetails ysEtlAssetDetails){
        return ResultObject.success(ysManageAssetService.updateManageAssetByNum(ysEtlAssetDetails));
    }

    @ApiOperation("删除资产")
    @GetMapping("/deleteByNum/{id}")
    public ResultObject<Boolean> deleteByNum(@PathVariable Long id){
        return ResultObject.success(ysManageAssetService.deleteByNum(id));
    }

    @ApiOperation("发布数据")
    @PostMapping("/releaseData")
    public ResultObject<Boolean> releaseData(@RequestBody YsBusinessBudgetDTO ysBusinessBudgetDto){
        return ResultObject.success(ysManageAssetService.releaseData(ysBusinessBudgetDto));
    }

    @ApiOperation("查询修订记录")
    @PostMapping("/getModifyRecordList")
    public ResultObject<PageInfo<YsAssetModifyRecords>> getModifyRecordList(@RequestBody YsBusinessBudgetDTO ysBusinessBudgetDto){
        return ResultObject.success(ysManageAssetService.getModifyRecordList(ysBusinessBudgetDto));
    }

    @ApiOperation("撤销")
    @PostMapping("/revokeRecord")
    public ResultObject<Boolean> revokeRecord(@RequestBody NumAndYardDTO dto){
        return ResultObject.success(ysManageAssetService.revokeRecord(dto));
    }

    @ApiOperation("导出")
    @PostMapping("/exportExcelYsManageAsset")
    public void exportExcelYsManageAsset(HttpServletResponse response, @RequestBody YsBusinessBudgetDTO dto) {
        ysManageAssetService.exportExcelYsManageAsset(response, dto);
    }
}
